<html>
 <head>
  <link href="./leetcode-problem.css" rel="stylesheet" type="text/css">
 </head>
 <body>
  <div class="question_difficulty">
   难度：Medium
  </div>
  <div>
   <h1 class="question_title">
    778. Reorganize String
   </h1>
   <p>
    Given a string
    <code>
     S
    </code>
    , check if the letters can be rearranged so that two characters that are adjacent to each other are not the same.
   </p>
   <p>
    If possible, output any possible result.&nbsp; If not possible, return the empty string.
   </p>
   <p>
    <strong>
     Example 1:
    </strong>
   </p>
   <pre>
<strong>Input:</strong> S = "aab"
<strong>Output:</strong> "aba"
</pre>
   <p>
    <strong>
     Example 2:
    </strong>
   </p>
   <pre>
<strong>Input:</strong> S = "aaab"
<strong>Output:</strong> ""
</pre>
   <p>
    <strong>
     Note:
    </strong>
   </p>
   <ul>
    <li>
     <code>
      S
     </code>
     will consist of lowercase letters and have length in range
     <code>
      [1, 500]
     </code>
     .
    </li>
   </ul>
   <p>
    &nbsp;
   </p>
  </div>
  <div>
   <h1 class="question_title">
    778. 重构字符串
   </h1>
   <p>
    给定一个字符串
    <code>
     S
    </code>
    ，检查是否能重新排布其中的字母，使得两相邻的字符不同。
   </p>
   <p>
    若可行，输出任意可行的结果。若不可行，返回空字符串。
   </p>
   <p>
    <strong>
     示例&nbsp;1:
    </strong>
   </p>
   <pre>
<strong>输入:</strong> S = "aab"
<strong>输出:</strong> "aba"
</pre>
   <p>
    <strong>
     示例 2:
    </strong>
   </p>
   <pre>
<strong>输入:</strong> S = "aaab"
<strong>输出:</strong> ""
</pre>
   <p>
    <strong>
     注意:
    </strong>
   </p>
   <ul>
    <li>
     <code>
      S
     </code>
     只包含小写字母并且长度在
     <code>
      [1, 500]
     </code>
     区间内。
    </li>
   </ul>
  </div>
 </body>
</html>